import { Model } from 'mongoose';
import { IAttachment } from '../models/types';
import { BaseRepository } from './BaseRepository';

export class AttachmentRepository extends BaseRepository<IAttachment> {
  private attachmentModel: Model<IAttachment>;

  constructor(model: Model<IAttachment>) {
    super(model);
    this.attachmentModel = model;
  }

  async findByHash(hash: string): Promise<IAttachment | null> {
    return this.attachmentModel.findOne({ hash }).lean().exec();
  }
}
